package cn.zcib.service;

import cn.zcib.dao.TeacherDao;
import cn.zcib.domain.Teacher;

/**
 * @Author Lucky赵
 * @Date 2021年08月11日 19:11
 */
public class TeacherService {
    private static final TeacherDao teacherDao = new TeacherDao();

    public boolean isExists(String id) {
        Teacher[] teachers = teacherDao.findAllTea();
        boolean flag = false;
        for (Teacher tea : teachers) {
            if (tea != null && tea.getId().equals(id)) {
                flag = true;
                break;
            }
        }
        return flag;
    }

    public boolean addTea(Teacher teacher) {
        return teacherDao.addTea(teacher);
    }

    public Teacher[] findAllTea() {
        //调用StudentDao中的addStu()方法获取学生对象
        Teacher[] allTea = teacherDao.findAllTea();
        //判断学生数组中是否有信息
        boolean flag = false;
        for (Teacher tea : allTea) {
            if (tea != null) {
                flag = true;
                break;
            }
        }
        if (flag)
            return allTea;
        else
            return null;
    }

    public void delTeaById(String id) {
        teacherDao.delTeaById(id);
    }

    public void updateStu(String id, Teacher teacher) {
        teacherDao.updateStu(id,teacher);
    }
}
